from django.db import models

# 单词
from django.utils import timezone


class Word(models.Model):
    text = models.CharField(max_length=100, null=True)  # 单词
    phonetic = models.CharField(max_length=200, null=True)  # 音标
    meaning = models.TextField(null=True)  # 中文意义
    trick = models.TextField(null=True)  # 窍门
    grade = models.IntegerField(default=0, null=True)  # 年级， 可以与当前同步


# 记忆检测
class RecallRecord(models.Model):
    word = models.ForeignKey(Word, on_delete=models.CASCADE)
    successes = models.IntegerField(default=0)  # 成功次数 0 <= successes <= total
    total = models.IntegerField(default=1)  # 总次数，1 <= total
    alpha = models.FloatField(default=3.)  # α，β， t
    beta = models.FloatField(default=3.)
    t = models.FloatField(default=24.)
    recall = models.IntegerField(default=0)
    last_test = models.DateTimeField(default=timezone.now)
    last_cal = models.DateTimeField(null=True)  # 最近计算
